/**
 * Created by dell on 2016/12/12.
 */
$(function(){

    //$.ajax({
    //    url: "http://api.sku.tea.goetui.com/api/classify.ashx",
    //    cache: false,
    //    dataType: "json",
    //    type: "get",
    //    success: function (result) {
    //        if(result.coords){
    //            $('#imgMap').append('<img src="'+result.src+'" usemap="#Map" usemap="#Map" ref="imageMaps" />');
    //
    //        }
    //    }
    //});
    var result={
        //"coords":["304,423,531,670", "90,210,240,600",],
        //"link":["https://www.baidu.com/","https://www.hao123.com/"],
        //"title":["茶壶","茶杯"],
        //"imgSrc":"../../resources/img/a1.jpg",
        "imgSrc":"magazine_03.jpg",
    }

    var _html=$('<map name="121212"></map>>');
    console.log(_html)
    $('#imgMap img').attr('src',''+result.imgSrc+'');

    if(result.coords){
        for(var i=0;i<result.coords.length;i++){
            $('#Map').append(' <area shape="rect" title="'+result.title[i]+'" href="'+result.link[i]+'" target="_blank" coords="'+result.coords[i]+'"/>');
            //.val(''+result.link[i]+'');
        }
    }else{
        $('#Map').append(' <area shape="rect" target="_blank"/>');
    }

    $('#imgMap').imageMaps();
    $('.button-conrainer input').click(function(){

    });
    $('.subMi').click(function(){
       var coordBox=$('.rect-value');
       if(coordBox.val()){
               var area=[];
               var link=$('.linkText')
               var coord=$(coordBox)
               var title=$('.titleText')
               for(var i=0;i<coordBox.length;i++){
                   var abc='<area href="'+$(link[i]).val()+'" title="'+$(title[i]).val()+'" coords="'+$(coord[i]).val()+'"/>';
                   area.push(abc);
               }
    }
        var json={
            data:area
        }
        console.log(json);
});
});

